<?php
namespace app\home\model;

use think\Db;

class FreightModel 
{
    /**
     * 单例模式
     *
     * @return FreightModel
     *
     */
    public static function instance(){
        static $m = null;
        if(!$m){
            $m = new FreightModel();
        }
        return $m;
    }
    /**
     * 页面展示
     *
     */
    public function show($bid){
        $field = 'freid,bid,title,unit,first,freight,next,freight1,createtime,status,type,handletime';
        $list = Db::name('freight')->field($field)->where('bid',$bid)->select();

        return $list;
    }
    /**
     * 添加数据库
     *
     */
    public function insert($data){
        
        $list = Db::name('freight')->insert($data);
        if($list){
            return $list;
        }else{
            echo '添加失败';
        }

    }
    /**
     * 详情
     */
    public function showdata($id){
        $list = Db::name('freight')->field('freid,bid,title,city,unit,first,freight,next,freight1,status,createtime')->where('freid',$id)->find();
        return $list;
    }
    /**
     * 上下架
     */
    public function soldOut($type){
        $type = Db::name('freight')->where('freid',$type['goodsid'])->update(['status'=>$type['status']]);
        return $type;
    }
    /**
     * 编辑
     */
    public function editinsert($data){
        $type = Db::name('freight')->update($data);
        return $type;
    }

}
